/**
 * 
 */
package ch.ifage.business.dom;

import java.util.GregorianCalendar;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * @author Christian
 *
 */
public class WorkflowTest {
	
	
	/**
	 * le workflow a tester.
	 */
	private Workflow wf;
	
	// step 1 ****************************************************
	/**
	 * identité du step.
	 */
	private StepIdentity si = new StepIdentity(1, "serverY", "instanceZ");
	
	/**
	 * départ.
	 */
	private GregorianCalendar start = new GregorianCalendar();
	
	/**
	 * fin.
	 */
	private GregorianCalendar end = new GregorianCalendar();
	
	/**
	 * propriété du step.
	 */
	private StepProperties sp;
	
	/**
	 * le 1er step.
	 */
	private FirstStep fs;	
	
	
	/**
	 * before.
	 */
	@Before
	public void init() {		
		end.add(GregorianCalendar.SECOND, 2); // durée de 2 secondes
		sp = new StepProperties("fichier.xml", 
                start, end, 
                Activity.ROUTER, 
                "parameter", 
                Status.SUCCESS, 
                "log");
		fs = new FirstStep(si, sp);
		wf = new Workflow(fs);
	}

	/**
	 * Test method for {@link ch.ifage.business.dom.Workflow#Workflow(ch.ifage.business.dom.FirstStep)}.
	 */
	@Test
	public final void testWorkflow() {
		Workflow wfNew = new Workflow(fs);
		Assert.assertFalse(wfNew.equals(null));
	}

	/**
	 * Test method for {@link ch.ifage.business.dom.Workflow#getFirstStep()}.
	 */
	@Test
	public final void testGetFirstStep() {
		FirstStep fsNew = wf.getFirstStep();
		Assert.assertTrue(fs.equals(fsNew));
	}
	
	/**
	 * Test method for {@link ch.ifage.business.dom.workflow#logContainsSubString(string)}.
	 */
	@Test
	public final void testlogContainsSubString() {
		Assert.assertTrue(wf.logContainsSubString("log"));
		Assert.assertFalse(wf.logContainsSubString("log3"));
	}

}
